package com.guigusuqi.app.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.R;
import com.guigusuqi.app.entity.PayUserOrderRegistration;
import com.guigusuqi.app.service.PayUserOrderRegistrationService;
import com.guigusuqi.commonutils.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  挂号-订单控制器
 * </p>
 *
 * @author suqi
 * @since 2022-06-16
 */
@RestController
@RequestMapping("/app/pay-user-order-registration")
public class PayUserOrderRegistrationController
{
    @Resource
    private PayUserOrderRegistrationService payUserOrderRegistrationService;

    /**
     * 定义监听类
     * @param registrationId
     * @return
     */
    @ResponseBody
    @GetMapping("/paySuccess/{registrationId}")
    public Result paySuccess(@PathVariable("registrationId") String registrationId)
    {
        LambdaQueryWrapper<PayUserOrderRegistration> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PayUserOrderRegistration::getRegistrationId, registrationId);
        int count = payUserOrderRegistrationService.count(queryWrapper);
        return count > 0 ? Result.success() : Result.fail();
    }
}

